import { dialog } from '@gis/lib/components/antd-dialog/index.js';
import { BasicMarker } from '../../js/BasicMarker.js';
import { BasicMarkers } from '../../js/BasicMarkers.js';
import { getMarkerIcon } from '../../js/icon.js';
import { yardCoordinateHotelCount } from '@gis/lib/api';
import { useUserInfoStore } from '@gis/lib/pinia/userInfo.js';
import { handleCommonRes } from '@gis/lib/utils/resolver.js';
import { openHomestayListDialog } from '../../../../views/net-room/opt.js';

/*
 * 网约房
 * */

class Marker extends BasicMarker {
  constructor({ map, data }) {
    super({ map, data });
    /* this.type: 这个type主要用于筛选,需要和filter-legend里面的type相对应 */
    this.type = 'wyf';
    super.create();
  }
  getIcon() {
    return getMarkerIcon(this.type);
  }
  getLabelContent() {
    return `<div class='marker_label'><p class='marker_label__name'>${this.data.yard_name}</p><p class='marker_label__count'>网约房数：${this.data.hotel_total}</p></div>`;
  }

  onClick() {
    openHomestayListDialog(this.data.yard_id);
  }
}

export default class Wyf extends BasicMarkers {
  constructor({ map }) {
    super();
    this.map = map;
  }
  createMarker(data) {
    return new Marker({ map: this.map, data });
  }
  async getDataAsync() {
    const { area_code } = useUserInfoStore();
    const data = await handleCommonRes(yardCoordinateHotelCount, { area_code: area_code });
    return data.map((item) => Object.assign(item, { lnglat: [item.longitude, item.latitude] }));
  }
}
